package com.eax.ControlLayer;
import com.eax.ModelLayer.*;
import java.util.ArrayList;

public class LendController {
	LendCollectionModel lendCollection;

	public LendController(){
		lendCollection = new LendCollectionModel();
	}

	public void addLend(int id, int copySerialNumber, int personId, String startDate, String returnDate, String lendingPeriodStart, String lendingPeriodReturn, String status){
		lendCollection.addLend(id, copySerialNumber, personId, startDate, returnDate, lendingPeriodStart, lendingPeriodReturn, status);
	}

	public LendModel findLendById(int id){
		LendModel i = null;
		for(LendModel l : lendCollection.getAllLends()){
			if(l.getId() == id){
				i = l;
			}
		}

		return i;
	}

	public int getHighestId(){
		int i = 0;

		for(LendModel c : lendCollection.getAllLends()){
			if(c.getId() > i){
				i = c.getId();
			}
		}

		return i;
	}

	public ArrayList<LendModel> getAllLends(){
		return lendCollection.getAllLends();
	}

	public void returnLend(int id){
		lendCollection.returnLend(id);

	}
}